package com.magic.gre.entity;

import com.magic.gre.helper.Contract;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: Lmoumou
 * Date: 2019-01-08 12:24
 * 文件名: WordsDetailsBean
 * 描述:
 */
public class WordsDetailsBean {
    private boolean isShowPara = false;//是否显示释义

    /**
     * id : 1080407668318298129
     * name : aboriginal
     * symbol : [,æbə'rɪdʒənl]
     * pronunciation : null
     * meaning : adj. being the first or earliest known of its kind present in a region 土著的，原始的
     * status : 1
     * sameWord : null
     * example : null
     * unirpe : true
     * cooked : false
     * meanings : ["adj. being the first or earliest known of its kind present in a region 土著的，原始的"]
     */

    private String id;
    private String name;
    private String symbol;
    private Object pronunciation;
    private String meaning;
    private int status;
    private String sameWord;
    private String example;
    private boolean unirpe;
    private boolean cooked;
    private String thesaurusId;
    private List<String> meanings;
    private String voicePath;//本地字段（语音地址）
    private boolean isShow=false;

    public boolean isShow() {
        return isShow;
    }

    public void setShow(boolean show) {
        isShow = show;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public Object getPronunciation() {
        return pronunciation;
    }

    public void setPronunciation(Object pronunciation) {
        this.pronunciation = pronunciation;
    }

    public String getMeaning() {
        return meaning;
    }

    public void setMeaning(String meaning) {
        this.meaning = meaning;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getSameWord() {
        if (sameWord == null) {
            return "";
        }
        return sameWord;
    }

    public void setSameWord(String sameWord) {
        this.sameWord = sameWord;
    }

    public String getExample() {
        return example;
    }

    public void setExample(String example) {
        this.example = example;
    }

    public boolean isUnirpe() {
        return unirpe;
    }

    public void setUnirpe(boolean unirpe) {
        this.unirpe = unirpe;
    }

    public boolean isCooked() {
        return cooked;
    }

    public void setCooked(boolean cooked) {
        this.cooked = cooked;
    }

    public List<MeanBean> getMeanings() {
        List<MeanBean> list = new ArrayList<>();
        if (meanings != null) {
            for (String str : meanings) {
                MeanBean meanBean = new MeanBean();
                if (str.contains(Contract.WORDS_N)) {
                    meanBean.setName(Contract.WORDS_N);
                    meanBean.setContent(str.substring(Contract.WORDS_N.length()));
                } else if (str.contains(Contract.WORDS_PRON)) {
                    meanBean.setName(Contract.WORDS_PRON);
                    meanBean.setContent(str.substring(Contract.WORDS_PRON.length()));
                } else if (str.contains(Contract.WORDS_ADJ)) {
                    meanBean.setName(Contract.WORDS_ADJ);
                    meanBean.setContent(str.substring(Contract.WORDS_ADJ.length()));
                } else if (str.contains(Contract.WORDS_ADV)) {
                    meanBean.setName(Contract.WORDS_ADV);
                    meanBean.setContent(str.substring(Contract.WORDS_ADV.length()));
                } else if (str.contains(Contract.WORDS_V)) {
                    meanBean.setName(Contract.WORDS_V);
                    meanBean.setContent(str.substring(Contract.WORDS_V.length()));
                } else if (str.contains(Contract.WORDS_NUM)) {
                    meanBean.setName(Contract.WORDS_NUM);
                    meanBean.setContent(str.substring(Contract.WORDS_NUM.length()));
                } else if (str.contains(Contract.WORDS_NUM)) {
                    meanBean.setName(Contract.WORDS_NUM);
                    meanBean.setContent(str.substring(Contract.WORDS_NUM.length()));
                } else if (str.contains(Contract.WORDS_PREP)) {
                    meanBean.setName(Contract.WORDS_PREP);
                    meanBean.setContent(str.substring(Contract.WORDS_PREP.length()));
                } else if (str.contains(Contract.WORDS_CONJ)) {
                    meanBean.setName(Contract.WORDS_CONJ);
                    meanBean.setContent(str.substring(Contract.WORDS_CONJ.length()));
                } else if (str.contains(Contract.WORDS_INTERJ)) {
                    meanBean.setName(Contract.WORDS_INTERJ);
                    meanBean.setContent(str.substring(Contract.WORDS_INTERJ.length()));
                } else if (str.contains(Contract.WORDS_NEAR)) {
                    meanBean.setName(Contract.WORDS_NEAR);
                    meanBean.setContent(str.substring(Contract.WORDS_NEAR.length()));
                }

                list.add(meanBean);
            }
        }

        //添加同义词
        MeanBean sameBean = new MeanBean();
        sameBean.setName("同义词.");
        sameBean.setContent(sameWord);
        list.add(sameBean);

        //添加例句
        MeanBean exampleBean = new MeanBean();
        exampleBean.setName("例.");
        exampleBean.setContent(example);
        list.add(exampleBean);

        return list;
    }

    public void setMeanings(List<String> meanings) {
        this.meanings = meanings;
    }

    public String getThesaurusId() {
        if (thesaurusId==null){
            return "";
        }
        return thesaurusId;
    }

    public void setThesaurusId(String thesaurusId) {
        this.thesaurusId = thesaurusId;
    }

    public String getVoicePath(String dirPath) {
        return dirPath + "/" + "wordaudio" + "/" + name + ".mp3";
    }

    public void setVoicePath(String voicePath) {
        this.voicePath = voicePath;
    }
}
